<?php

namespace App\Http\Controllers\Kms\Backend\Feishu;

use App\Http\Controllers\BaseController;
use App\Service\Kms\Attendance\AttendanceService;
use App\Service\Kms\Common\FeishuService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class FeishuController extends BaseController
{
    /**
     * @return JsonResponse
     */
    public function departments(): JsonResponse
    {
        return $this->success(FeishuService::departments());
    }

    /**
     * @param Request $request
     * @return JsonResponse
     */
    public function user(Request $request): JsonResponse
    {
        $pageSize     = (int)$request->get("pageSize", 10);
        $pageNum      = (int)$request->get("pageNum", 1);
        $departmentId = $request->get("departmentId", "");
        $jobTitle     = $request->get("jobTitle", "");
        $name         = $request->get("name", "");
        $fieldSwitch  = $request->get("fieldSwitch", null);
        $selection    = (int)$request->get("selection", 0);

        return $this->success(FeishuService::user(
            $pageSize,
            $pageNum,
            $departmentId,
            $jobTitle,
            $name,
            $fieldSwitch,
            $selection
        ));
    }

    /**
     * @return JsonResponse
     */
    public function selection(): JsonResponse
    {
        return $this->success(FeishuService::selection());
    }
}
